package com.demo.yuanzi.config;

import cn.dev33.satoken.stp.StpInterface;
import com.demo.yuanzi.util.LoginSaRoleAndPermission;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Component
public class SaServiceImpl implements StpInterface {
    @Resource
    private LoginSaRoleAndPermission loginSaRoleAndPermission;
    @Override
    public List<String> getPermissionList(Object loginId, String yuan) {
        // 本 list 仅做模拟，实际项目中要根据具体业务逻辑来查询权限
        int id = 1;
        List<String> permissionList = loginSaRoleAndPermission.getPermissionList(id);
        permissionList.forEach(System.out::println);


        return permissionList;
    }

    /**
     * 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
     */
    @Override
    public List<String> getRoleList(Object loginId, String yuan) {

        // 本 list 仅做模拟，实际项目中要根据具体业务逻辑来查询角色
        int id = 1;

        List<String> roleList = loginSaRoleAndPermission.getRoleList(id);
        roleList.forEach(System.out::println);


        return roleList;
    }
}
